#ifndef __MARS_GP_CL_MGR_H__
#define __MARS_GP_CL_MGR_H__

#include "MarsObject.h"
#include "MarsSingleton.h"
#include "MarsGPConstants.h"
#include "MarsGPPlatform.h"
#include "MarsGPContext.h"
#include "MarsGPDevice.h"

using namespace Core;

namespace GP
{

class CLMgr : public Object, public Singleton< CLMgr >
{
public:
	bool							Initialize();
	void							Shutdown();

	void							SetCurrentPlatform( PlatformVendor ePlatform );

	PlatformVendor					GetCurrentPlatform() const;
	cl_platform_id					GetCurrentPlatformId() const;

	ContextPtr						CreateContext( const DevicePtr& device );

private:
									CLMgr();
									~CLMgr();

									MARS_NO_INIT_ASSIGNMENT( CLMgr );

	PlatformVendor					m_ePlatform;

	typedef std::vector< PlatformPtr >	PlatformVec;
	typedef PlatformVec::iterator		PlatformVecItr;
	typedef PlatformVec::const_iterator PlatformVecConstItr;

	PlatformVec						m_vecPlatforms;
	PlatformPtr						m_platform;

	friend class Singleton< CLMgr >;
};

inline CLMgr::CLMgr()
	: m_ePlatform( PlatformVendor_Unknown )
{

}

inline PlatformVendor CLMgr::GetCurrentPlatform() const
{
	return m_ePlatform;
}

} // end of namespace GP

#endif // end of #ifndef __MARS_GP_CL_MGR_H__